<template>
    <div class="wallet">
        <div class="total">
            <div class="all">
                <div>{{userInfo.jifen}}</div>
                <div class="text">积分</div>
            </div>
            <div class="withdrawl" @click="eventClickDH">我要兑换</div>
            <!--            <div class="bottom-type">-->
            <!--                <div class="end achievement">-->
            <!--                    <div class="img-title">-->
            <!--                        <img src="../../../static/images/shouru.png" alt="">-->
            <!--                        <span>总积分</span>-->
            <!--                    </div>-->
            <!--                    <div>￥{{ (parseFloat(userInfo.price) + parseFloat(userInfo.txprice)).toFixed(2) }}</div>-->
            <!--                </div>-->
            <!--                <div class="start achievement">-->
            <!--                    <div class="img-title">-->
            <!--                        <img src="../../../static/images/card-mini.png" alt="">-->
            <!--                        <span>已提现</span>-->
            <!--                    </div>-->
            <!--                    <div>￥{{userInfo.txprice}}</div>-->
            <!--                </div>-->
            <!--            </div>-->
        </div>
        <div class="profit-details">
            <title-normal title="积分明细" class="header"/>
        </div>
        <!--订单明细循环大包围-->
        <div class="wallet_detail">
            <!--循环体-->
            <van-list v-model="loading" :finished="finished" finished-text="没有更多了"
                      @load="getOrderLog">
                <div class="wallet_detail_cycle" v-for="item in budget">
                    <!--左边栏-->
                    <div class="wallet_detail_cycle_left">
                        <span>{{item.time}}</span>
                    </div>
                    <!--中间栏-->
                    <div class="wallet_detail_cycle_middle">
                        <span>{{item.status==1?'订单收入':'兑换积分'}}</span>
                        <span v-if="item.status == 1"
                              style="font-size: 1.3rem;font-weight: 500;color: #999999">订单编号:{{item.ordernumber}}</span>
                        <!--                        <span v-if="item.status==2 && item.orderStatus==1"-->
                        <!--                              style="font-size: 1.3rem;font-weight: 500;color: #FF0000">提现申请 审核中</span>-->
                        <!--                        <span v-if="item.status==2 && item.orderStatus==0"-->
                        <!--                              style="font-size: 1.3rem;font-weight: 500;color: #FF0000">提现申请 已拒绝</span>-->
                        <!--                        <span v-if="item.status==2 && item.orderStatus==2"-->
                        <!--                              style="font-size: 1.3rem;font-weight: 500;color: #999999">提现申请 已通过</span>-->
                    </div>
                    <!--右边栏-->
                    <div class="wallet_detail_cycle_right">
        <span v-if="item.status == 1"
              style="color:#00CC00;font-weight: 500;font-size: 1.9rem ">+ {{item.price}}</span>
                        <span v-if="item.status == 2"
                              style="font-size: 1.9rem;font-weight: 500;color:#FF0000 ">- {{item.jfprice}}</span>
                    </div>
                </div>
            </van-list>
        </div>
    </div>
</template>

<script>
    import TitleNormal from '../../components/currency/title/normal.vue';
    import {DatetimePicker, Popup, List,Dialog} from 'vant';

    export default {
        name: "wallet",
        components: {
            TitleNormal,
            [DatetimePicker.name]: DatetimePicker, [Popup.name]: Popup, [List.name]: List
        },
        data() {
            return {
                endM: 500.0,
                type: 1, //收入明细订单状态控制
                earnings: 1, //收入金钱状态控制
                page: 0,
                list_rows: 10,
                budget: [],
                loading: false,
                finished: false
            }
        },
        computed: {
            userInfo() {
                return this.$store.state.options.user.oda;
            }
        },
        created() {
        },
        mounted() {
            this.getPrice()
        },
        methods: {
            eventClickDH() {
                var that = this;
                var url = '/api/home/user/jifenDH';
                var param = {
                    token: this.$store.state.options.user.token
                };
                this.$util.postRequestInterface(url, param, (res) => {
                    Dialog.alert({
                        title:'提示',
                        message:res.msg
                    }).then(()=>{
                        that.getPrice();
                    });
                })
            },
            getPrice() {
                var url = '/api/home/user/getone';
                this.$util.postRequestInterface(url, {token: this.$store.state.options.user.token}, (res) => {
                    this.userInfo.jifen = res.data.jifen;
                    this.userInfo.txprice = res.data.txprice
                })
            },
            getOrderLog() {
                var that = this;
                var url = '/api/home/order/getLog';
                var param = {
                    page: this.page,
                    list_rows: this.list_rows,
                    jifen: 1,
                    token: this.$store.state.options.user.token
                };
                this.$util.postRequestInterface(url, param, (res) => {
                    that.page = that.page + 1;
                    if (res.data == '') {
                        that.loading = false;
                        that.finished = true;
                    } else {
                        for (let i of res.data.data) {
                            that.budget.push({
                                status: i.status,
                                orderStatus: i.orderstatus,
                                price: i.price,
                                jfprice:i.jfprice,
                                time: that.$moment(i.addtime * 1000).format('YYYY-MM-DD HH:mm:ss'),
                                ordernumber: i.ordernum
                            });
                        }
                        // // 加载状态结束
                        that.loading = false;
                        // // 数据全部加载完成
                        if (that.budget.length >= res.data.count) {
                            that.finished = true;
                        }
                    }
                })
            },
            eventClickWithdrawl() {
                this.$router.push({
                    path: '/shop/withdrawal',
                    query: {
                        price: this.userInfo.price
                    }
                })
            }
        }
    }
</script>

<style scoped lang="scss">
    .wallet {
        .total {
            background-image: url("../../../static/images/back-ripple.png");
            background-size: 100% 111%;
            padding: 2rem 2rem 4rem;
            color: #ffffff;
            display: flex;
            flex-wrap: wrap;

            .all {
                width: 100%;
                text-align: center;

                div:first-child {
                    font-size: 5.5rem;
                }

                .text {
                    font-size: 2rem;
                }

            }

            .withdrawl {
                padding: .4rem 1rem;
                margin: 0 auto;
                margin-top: 1rem;
                /*width: 20%;*/
                background: #ffffff;
                color: #00CC00;
                border-radius: .6rem;
                font-size: 1.4rem;
            }

            .bottom-type {
                width: 100%;
                padding-top: 2.4rem;
                display: flex;
                justify-content: space-between;
                padding-bottom: 4rem;

                .achievement {
                    flex: 1;
                    text-align: center;

                    .img-title {
                        padding-bottom: .8rem;

                        img {
                            width: 1.5rem;
                            height: 1.5rem;
                            vertical-align: bottom;
                        }
                    }
                }

                .achievement:first-child {
                    border-right: 0.01rem solid #DDDDDD;
                }
            }
        }

        .profit-details {
            padding: 1rem;

            .header {
                padding-bottom: 1rem;
                border-bottom: 0.01rem solid #DDDDDD;
            }
        }

        /*收支明细循环体大包围*/
        .wallet_detail {
            width: 100%;
            /*循环体*/
            .wallet_detail_cycle {
                width: 95%;
                margin: 0 auto;
                display: flex;
                align-items: center;
                border-bottom: 1px solid #EEEEEE;
                margin-top: 1rem;
                padding-bottom: 1rem;
                /*循环体左部*/
                .wallet_detail_cycle_left {
                    width: 25%;
                    text-align: right;

                    span {
                        font-weight: 500;
                        font-size: 1.3rem;
                        color: #999999;
                    }
                }

                /*循环中部*/
                .wallet_detail_cycle_middle {
                    width: 50%;
                    display: flex;
                    flex-direction: column;
                    padding-left: 1rem;

                    span {
                        line-height: 2rem;

                        &:nth-child(1) {
                            font-size: 1.7rem;
                            color: #333333;
                            font-weight: 500;
                        }
                    }
                }

                /*循环右部*/
                .wallet_detail_cycle_right {
                    width: 25%;
                    text-align: right;
                    padding-right: 1rem;
                }
            }
        }
    }
</style>